package com.guojiaming.shop.bean;

import com.google.gson.annotations.Expose;
import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;

/**
 * @author vivo
 */
@Validated
public class User {
    @Expose
    @Null
    private Integer userId;
    @Expose
    @NotNull
    @Length(min = 2, max = 20)
    private String userName;
    @Length(min = 6, max = 22)
    @Expose(serialize = false)
    @NotNull
    private String userPass;
    @Length(min = 11, max = 11)
    @Expose
    @NotNull
    private String userPhone;
    @Expose
    private Date userBirthday;


    public static User getInstance(UserModity userModity) {
        User user = new User();
        user.userId = userModity.getUserId();
        user.userName = userModity.getUserName();
        user.userPhone = userModity.getUserPhone();
        user.userBirthday = userModity.getUserBirthday();
        return user;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPass() {
        return userPass;
    }

    public void setUserPass(String userPass) {
        this.userPass = userPass;
    }

    public String getUserPhone() {
        return userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public Date getUserBirthday() {
        return userBirthday;
    }

    public void setUserBirthday(Date userBirthday) {
        this.userBirthday = userBirthday;
    }
}